<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>我的微博</title>
</head>
<body>
<h1>我发布的微博</h1>
<div>
    <div v-for="weibo in arr">
        <h3>{{weibo.title}}<a href="javascript:void(0)" @click="del(weibo.id)">  删除</a></h3>
        <p>{{weibo.content}}</p>
        <img :src="weibo.url" style="width: 200px" alt="">
    </div>
</div>

<!--引入axios和vue-->
<script src="js/axios.min.js"></script>
<script src="js/vue.js"></script>
<script>
    let v = new Vue({
        el:"body>div",
        data:{
            arr:[]
        },
        created:function () {
            //请求当前登录用户发布的所有微博
            axios.get("/weibo/select/my").then(function (response) {
                //判断出未登录的状态
                if (response.data.status == 2){
                    alert("请登录!")
                    location.href = "/login.html"
                    return;
                }
                v.arr = response.data.content;
            })
        },
        methods:{
            del:function (id) {
                if (confirm("确定删除?")){
                    axios.get("/weibo/delete?id="+id).then(function () {
                        location.reload();
                    })
                }
            }
        }
    })
</script>
</body>
</html>